tut for mike's torso ?

Discussion in 'Scripting' started by LeBabouin, Sep 24, 2005.

  1. LeBabouin Papio anubis

    Contributions:
    509
    Specialties:
    Scripting
    Processing:
    Graphics:
    PREMIUM
    I Donated
    Someone to link me to a tut for mike's torso :sick: ?
  2. vassilie_zaitsev Staff Sergeant

    Contributions:
    56
    Specialties:
    Mapper, Scripting, Programming, Pure Gamer
    Processing:
    Graphics:
    Whaaaaaaaaaaaaaaa???

    Whos Torso, and WTF is it ??? lol
  3. Elgan Captain

    Contributions:
    315
    Specialties:
    Modeler, Scripting, Programming, Pure Gamer, Support
    Processing:
    Graphics:
    PREMIUM
    I Donated
    there is no tutorial.

    tbh it's not that hard., you just have to get the structure of them.

    What is it your trying to do and maybe we can come up with a "tutorial" on that.
  4. Petey Founder/CEO of San Diego

    Contributions:
    122
    Processing:
    Graphics:
    PREMIUM
    I Donated
    mikes torso is the state file for game which controls various movements such as stand, crouch, climb, raise weapon, etc...
  5. LeBabouin Papio anubis

    Contributions:
    509
    Specialties:
    Scripting
    Processing:
    Graphics:
    PREMIUM
    I Donated
    I'd like to make the server play the .30 Cal firing sound in a converted sp (e1l1) that has no aliases in ubersound, and sorrid suggested to create a "DO_GUN_SOUND" state in torso, but that's no so clear to me. I can't figure where to place it and what it has to be related to. http://www.modtheater.com/forum/thread26759.html
  6. @(...:.:...)@ Hal

    Contributions:
    326
    Specialties:
    Scripting, Textures, Programming
    Processing:
    Graphics:
    PREMIUM
    I Donated
    Ok, I will write a bit about it ;) I will edit this post with it in a sec. :)
  7. LeBabouin Papio anubis

    Contributions:
    509
    Specialties:
    Scripting
    Processing:
    Graphics:
    PREMIUM
    I Donated
    I was secretly hoping your always clear and precise explanations :read: .
  8. @(...:.:...)@ Hal

    Contributions:
    326
    Specialties:
    Scripting, Textures, Programming
    Processing:
    Graphics:
    PREMIUM
    I Donated
    Hehe, here you go :read:.

    Ok then, here is a pretty good example. Here are some of the reload states which control weapon reloading.

    Code:
    //==============================================================================
          state RELOAD_WEAPON
          {
          	states
          	{
     	 RELOAD_SPRINGFIELD	: IS_WEAPON_ACTIVE "mainhand" "Springfield '03 Sniper"
     		RELOAD_SPRINGFIELD	: IS_WEAPON_ACTIVE "mainhand" "KAR98 - Sniper"
      		RELOAD_SHOTGUN 	: IS_WEAPON_ACTIVE "mainhand" "Shotgun"
     		RELOAD_NAGANTREV	: IS_WEAPON_ACTIVE "mainhand" "Nagant Revolver"
     		RELOAD_WEBLEY 	: IS_WEAPON_ACTIVE "mainhand" "Webley Revolver"
          
     		RELOAD_PISTOL 	: IS_WEAPONCLASS_ACTIVE "mainhand" "pistol"
     		RELOAD_RIFLE 	: IS_WEAPONCLASS_ACTIVE "mainhand" "rifle"
     		RELOAD_RIFLE 	: IS_WEAPON_ACTIVE "mainhand" "Gewehrgranate"		
     		RELOAD_SMG 		: IS_WEAPONCLASS_ACTIVE "mainhand" "smg"
     		RELOAD_MG 		: IS_WEAPONCLASS_ACTIVE "mainhand" "mg"
     		RELOAD_GRENADE 	: IS_WEAPONCLASS_ACTIVE "mainhand" "grenade"
     //		RELOAD_PISTOL 	: IS_WEAPONCLASS_ACTIVE "mainhand" "item" // hold all items like a pistol for now
     		RELOAD_HEAVY 	: IS_WEAPONCLASS_ACTIVE "mainhand" "heavy"
          
     		RELOAD_RIFLE		: default	
          	}
          }
          
    This is if you like the master state of the reload section. This state is started from somewhere else in mike torso when you should be reloading.

    State RELOAD_WEAPON is the name of the state. This acts in much the same way as a script threads name.

    The 'stuff' for RELOAD_WEAPON is contained within the furthest left pair of curly brackets, in the same way as normal scripting. Within this first pair you can have a number of differnt things which I will get to in a minute. This state just has states to go to, with no animations to play, which makes it quite easy.
    Code:
          states
          {
          //states here
          MY_STATE 		: STUFF_TO_EVAUATE
          }
          
    "States" contains the possible options for where to 'go to' after this state. This works kind of like an if statement. Think of the " : " as "if", and the stuff after as statements which need to be evaluated. so in english, the top state; "RELOAD_SPRINGFIELD" goes like this: "if the player is holding a Springfield (Iin the mainhand), then go to the state RELOAD_SPRINGFIELD"

    It will go through the list from top to bottom, evaluating the statements to see if they are true. You can also use '!' to say if this is not happening, for example:

    Code:
    		STAND 		 	: !IS_WEAPON_READY_TO_FIRE "mainhand"
    That is a state from attack semi auto. This will go back to STAND (which is the base state which everything starts from) if a player tries to make a semi auto attack when the weapon is not ready. (For example doing an animation, so can't attack.) E.G "if the player does not have a weapon which is ready to fire, go to STAND"

    Back to the reloading state. Lets say we are trying to reload an enfield. So in the state list of RELOAD_WEAPON it starts checking the states. We are not holding a springfield, so no; next state, we are not holding a sniper, so no. Skip a few; our weapon class is not pistol, so not that, then the next one is true. The enfield is a rifle (weapontype rifle" line in tik) so this line is evaluated to be true, and the state RELOAD_RIFLE now starts, which is this:


    Code:
    state RELOAD_RIFLE
          {
          	movetype legs
          
          	entrycommands
          	{
          		zoomoff
          		viewmodelanim reload
          	}
          
          	action
          	{
     		kar98_reload 	: IS_WEAPON_ACTIVE "mainhand" "Gewehrgranate"
     		kar98_reload 	: IS_WEAPON_ACTIVE "mainhand" "Mauser KAR 98K"
     		enfield_reload 	: IS_WEAPON_ACTIVE "mainhand" "Lee-Enfield"
     		svt_reload		: IS_WEAPON_ACTIVE "mainhand" "SVT 40"
     		mosin_reload 	: IS_WEAPON_ACTIVE "mainhand" "Mosin Nagant Rifle"
     		g43_reload		: IS_WEAPON_ACTIVE "mainhand" "G 43"
          		rifle_reload		: default
          	}
          
          	states
          	{
     		STAND 			 : KILLED
     		STAND 			: ANIMDONE_TORSO
          		RELOAD_INTERUPTED	: NEW_WEAPON
          		
          		RELOAD_INTERUPTED	: IS_USING_VEHICLE
          		RELOAD_INTERUPTED	: IS_USING_TURRET
          
          		// Note that this is ok since sniper rifles don't come through here
       		//RELOAD_INTERUPTED_SECONDARYATTACK	: +ATTACK_SECONDARY
          	}
          }
          
    entrycommands are commands you can set to be run when the state starts. In this case it turns of the scope, and does viewmodelanim reload. You can put exec lines here to start scripts, which is very usefull.

    You can also have exitcommands in the same way, exept the commands are run when the state and its animations have finished.
    exitcommands
    {
    //commands here
    exec global/myscript.scr "a variable"
    }

    Adding variable to the exec line is a usefull to. :)

    The "action" section are all of the animations which could be run. This works like the "states" section. So, the first line, "if the player is holding a rifle grenade, do the animation kar98_reload." This links to the models/player/base/ files.

    eg:

    Code:
    	//========================
          	// Reload KAR98
          	//========================
     	kar98_reload	 viewmodel/rifle/tps_kar98_reload.skc 	crossblend 0.05
          	{
          		server
          		{
          			first reloadweapon
     		 0	attachmodel models/ammo/kar98_clip_reload.tik tag_weapon_right		 // tell the weapon that we're reloading
     		 1	weaponcommand mainhand attachtohand offhand		 		// attach the weapon to the left hand
     		 50	weaponcommand mainhand clip_fill 		 		// put the clip ammo into the gun
     		 50	removeattachedmodel tag_weapon_right 0 models/ammo/kar98_clip_reload.tik	// remove the clip model from the right hand
     		 last	weaponcommand mainhand attachtohand mainhand		 		// reattach the weapon to the right hand
          		}
          	}

    After that, there are states again which tell it where to go next. Eg, if you are killed while reloading, it goes to stand, which will then go to the killed state to play a death animation. If you change weapon, it will go to RELOAD_INTERUPTED, etc.

    There must always be somewhere for the state to go next. It can crash the game quite eaysily if it gets stuck and you have a loop, or you tell it to start a state which doesnt exist, or an animation which doesnt exist.

    That is the basics I supose. The best way to learn and understand the state files is to make mods with them :) Be carefull though, once you start using them you won't be able to make mods without them :crying: .

    Ask if you have any questions. :waves:

    Btw, the turrets (and vehichles) do not use state files. :eek: There are some states for both at the bottom of mike torso, but nothing major, such as movement or firing. They just control getting on and off.:eek:

    For the 30 cal, In theory you could edit the full auto state file to include options for the 30 cal, but because of the guns classname, it proberbly wont use the torso/leg state files. :(

    Hmm I just re read the http://www.modtheater.com/forum/showthread.php?p=226255#post226255 thread. I see you were asking why the dmt sound works in maps. :) I thought you coulden't get it to work when I first read it. :) It is a tricky situation though. I think the only way you can get the 30 cal sounds to play is with a scriptmaster cache, or with a clientside ubersound file. sorridstroker's method of caching sounds server side would work if you can make a state in mike torso, and put playsound, but because I think you cannot do that for turret/vehicle guns the only way is the scriptmaster cache.:shake:

    I have cached a 30 cal sound before when I was messing about with using the jeeps 30 cal as a normal turret weapon, like an mg42, and the sounds cached fine in spearhead. I will see if it works in breakthrough also.

    Could you tell me the tik and sound file/alias you are trying to play? :)

    Btw, have you done some tests with restarting? Eg does it take a long time to restart if there is a) no map script, or b) you use a DM_Manager to restart? Have you tried dedicated and non dedicated server (on your pc)? I think you can run a dedicated server, and connect to it from the same instilation of bt.
    4 people like this.
  9. LeBabouin Papio anubis

    Contributions:
    509
    Specialties:
    Scripting
    Processing:
    Graphics:
    PREMIUM
    I Donated
    Code:
    state CHECK_MORTARRIFLE
    {
     movetype legs
     action
     {
      none : default // stop torso animation
     }
     states
     {
      STAND    : KILLED 
      STAND    : NEW_WEAPON
      STAND    : RELOAD
      ATTACK_KAR98MORTAR_PRIMARY : IS_WEAPON_READY_TO_FIRE "mainhand" WEAPON_CURRENT_FIRE_ANIM "mainhand" "[COLOR=red]0[/COLOR]"
      ATTACK_KAR98MORTAR_PRIMARY : IS_WEAPON_READY_TO_FIRE "mainhand" WEAPON_CURRENT_FIRE_ANIM "mainhand" "[COLOR=red]2[/COLOR]"//***sorrid
      ATTACK_KAR98MORTAR_SECONDARY : IS_WEAPONCLASS_READY_TO_FIRE "mainhand" "heavy" "secondary" WEAPON_CURRENT_FIRE_ANIM "mainhand" "[COLOR=red]1[/COLOR]"
      STAND    : !ATTACK_PRIMARY
     }
    }

    What do the figures in red do? (this is from the rifle mortar bash by sorrid)
  10. @(...:.:...)@ Hal

    Contributions:
    326
    Specialties:
    Scripting, Textures, Programming
    Processing:
    Graphics:
    PREMIUM
    I Donated
    WEAPON_CURRENT_FIRE_ANIM is a variable that can hold an integer number which you can use directly in the state file. :)
  11. Elgan Captain

    Contributions:
    315
    Specialties:
    Modeler, Scripting, Programming, Pure Gamer, Support
    Processing:
    Graphics:
    PREMIUM
    I Donated
    this is on MRU somewhere along with other lists.

    thought id post it here. might not be here. not sure.


    ATTACK_SECONDARY
    ATTACK_PRIMARY_BUTTON
    ATTACK_PRIMARY
    DUCKED_VIEW_IN_WATER
    VIEW_IN_WATER
    CHECK_HEIGHT
    GROUNDENTITY
    STATE_ACTIVE
    SOLID_FORWARD
    FACING_DOWN_SLOPE
    FACING_UP_SLOPE
    CAN_STAND
    CAN_GET_OFF_LADDER_BOTTOM
    CAN_GET_OFF_LADDER_TOP
    CAN_CLIMB_DOWN_LADDER
    CAN_CLIMB_UP_LADDER
    ON_LADDER
    AT_TOP_OF_LADDER
    LOOKING_UP
    AT_LADDER
    CAN_PULL
    CAN_PUSH
    LOOP_USEOBJECT
    AT_USEOBJECT
    FINISHEDUSEANIM
    TOUCHEDUSEANIM
    AT_USEANIM
    TORSO
    LEGS
    KNOCKDOWN
    PAIN_THRESHOLD
    PAIN_LOCATION
    PAIN_DIRECTION
    PAIN_TYPE
    KILLED
    HARD_IMPACT
    MEDIUM_IMPACT
    FALLING
    AT_DOOR
    CAN_FALL
    LEFT_LEG_HIGH
    RIGHT_LEG_HIGH
    SLOPE_45
    SLOPE_22
    HAS_VELOCITY
    DOWN_VELOCITY
    UP_VELOCITY
    FORWARD_VELOCITY
    BACKWARD_VELOCITY
    RIGHT_VELOCITY
    LEFT_VELOCITY
    CAN_TURN
    ACTION_ANIMDONE
    ANIMDONE_TORSO
    ANIMDONE_LEGS
    DO_JUMP_FLIP
    CROUCH
    JUMP
    STRAFE_RIGHT
    STRAFE_LEFT
    BACKWARD
    FORWARD
    RIGHT
    LEFT
    USE
    RUN
    MOVEMENT_TYPE
    POSITION_TYPE
    EW_WEAPON_IS_ITEM
    IS_WEAPON_AN_ITEM
    WEAPONS_HOLSTERED
    RELOAD
    HAS_AMMO_IN_CLIP
    HAS_AMMO
    MUZZLE_CLEAR
    BLOCK_DELAY
    TURRET_TYPE
    IS_USING_TURRET
    IS_DRIVER
    IS_PASSENGER
    VEHICLE_TYPE
    IS_USING_VEHICLE
    IS_WEAPONCLASS_READY_TO_FIRE
    IS_WEAPONCLASS_ACTIVE
    IS_NEW_WEAPONCLASS
    MIN_CHARGE_TIME_MET
    IS_WEAPON_SEMIAUTO
    ATTACK_BLOCKED
    ANY_WEAPON_ACTIVE
    PUTAWAYOFFHAND
    PUTAWAYMAIN
    IS_WEAPON_READY_TO_FIRE_NOSOUND
    IS_WEAPON_READY_TO_FIRE
    IS_WEAPON_ACTIVE
    IS_NEW_WEAPON
    IMMEDIATE_SWITCH
    NEW_WEAPON
    HAS_WEAPON
    ONGROUND
    BLOCKED
    HEALTH


    note this movetype list may be missing some.

    coolobject
    useobject
    loopuseanim
    useanim
    climbwall
    push
    pickupenemy
    rope_move
    rope_release
    rope_grab
    hanging
    absolute
    user_moveanim
    legs
    user
    crouch
  12. ColonelIT Private

    Contributions:
    0
    This just isn't true! I have spent days looking for a tutorial (or any GOOD information) on weapons modding using the state files and have not found ONE! I tried Admin Pro 1.22 for modding weapons for Spearhead and it doesn't work right all of the time.

    I tried modding the mike_torso.st file myself using info from this site and it doesn't work. So, my comment is.... SHOW ME!
  13. Herr Klugscheisser No longer supporting WarGaming

    Contributions:
    370
    Specialties:
    Scripting, Support
    Processing:
    Graphics:
    PREMIUM
    I Donated
    Maybe it doesn't work for you, but it definitely works. Look at other peoples work , study it, formulate a basic understanding and then ask specific questions.

    "I tried this(give example), but it seems to have no effect. Any ideas?"

    "This sorta works (give example), but not exactly the way I want. Can someone point me in the right direction?"

    Etc ....

    Teaching yourself is the most rewarding, but there are plenty of people who can/will help when they can and they have some idea what you are trying to achieve.
  14. ColonelIT Private

    Contributions:
    0
    Thanks Herr Klugscheisser....and please help

    Okay, point taken. So, here is some information on what I have done and what I am trying to do:

    I tried using Admin Pro 1.22 for the weapon mods I wanted but it doesn't work consistently. If someone is in the server alone and someone else spawns and it forces a respawn, all weapons become available. So I decided to go the painful route and learn to write my own mods.

    So, my goal here is to create a fairly standard mod which is rifles only, no nades, and no pistol ammo. I have created a modded PK3 that contains the TIKI files with the changes I made to eliminate nades, smg's, etc. I tested this and it works.

    Then, after much research I found a thread in the forums on the mike_torso.st file and attempted to change one weapon (BAZOOKA) as a test. After crashing the server a couple of times with syntax errors, I got it to run but it doesn't work. Here is the code:

    Code:
    state RAISE_WEAPON
    {
     movetype legs
     entrycommands
     {
      viewmodelanim pullout
      // just to make sure nothing funky's 
      // attached that shouldn't be.
      correctweaponattachments
     }
     states
     {
      RAISE_PISTOL  : IS_NEW_WEAPONCLASS "mainhand" "pistol"
      RAISE_BAZOOKA  : IS_NEW_WEAPONCLASS "mainhand" "Bazooka"
      RAISE_RIFLE   : IS_NEW_WEAPONCLASS "mainhand" "rifle"
      RAISE_GRENADE  : IS_NEW_WEAPONCLASS "mainhand" "grenade"
      RAISE_SMG   : IS_NEW_WEAPONCLASS "mainhand" "smg"
      RAISE_MG   : IS_NEW_WEAPONCLASS "mainhand" "mg"
    //  RAISE_PISTOL  : IS_NEW_WEAPONCLASS "mainhand" "item" // hold all items like a pistol for now
      RAISE_HEAVY   : IS_NEW_WEAPONCLASS "mainhand" "heavy"
      RAISE_PAPERS  : IS_NEW_WEAPON "mainhand" "Papers"
     
    //  RAISE_RIFLE   : default
      RAISE_NOANIM  : default
     }
    }
    state RAISE_NOANIM
    {
     entrycommands
     {
      // delay the activation for a frame so that the player
      // spends at least one frame without a weapon, thus 
      // letting the legs state know that we've switched
      commanddelay 0.05 activatenewweapon
      commanddelay 0.05 forcetorsostate "STAND"
     }
    // states
    // {
    //  STAND  : default
    // }
    }
    state RAISE_BAZOOKA
    { entrycommands
    { takeall
    give "models/weapons/Mosin_Nagant_Rifle.tik"
    wait 1
    stufftext "useweaponclass rifle"
    }
    states
    {
    STAND : KILLED
    STAND : ANIMDONE_TORSO
    RAISE_ABORT : +NEW_WEAPON
    }
    }
    state RAISE_RIFLE
    {
     movetype legs
     
     action
     {
      rifle_crouch_raise : POSITION_TYPE "crouching"
      rifle_stand_raise : default
     }
     
     states
     {
      STAND     : KILLED
     
      STAND     : ANIMDONE_TORSO
     
      // allow immediate switching to a different weapon instead
      RAISE_ABORT   : +NEW_WEAPON
     }
    }
  15. gooser13 Private First Class

    Contributions:
    8
    I believe you cannot run these commands in the state file. You must place them in a seperate script then exec the script from the state file.

    Code:
    state RAISE_BAZOOKA
    {
    	movetype legs
    
    	entrycommands
    	{
    		[COLOR="Red"]exec global/changeweapon.scr[/COLOR]
    		// just to make sure nothing funky's
    		// attached that shouldn't be.
    		correctweaponattachments
    
    
    	}
    
  16. spam jammer Private

    Contributions:
    68
    yup. also you dont need to make a scr file for every swap. you can thread them all so do what he said but with something like this around it

    Nagant:
    --code here--
    end

    so

    Nagant:
    takeall
    give "models/weapons/Mosin_Nagant_Rifle.tik"
    wait 1
    stufftext "useweaponclass rifle"
    end

    then you can execute that specific thread the same way he said but with a :: and then the thread name.
    eg
    exec global/changeweapon.scr::Nagant

    if you do it this way you can put all different weapons to swap in the same .scr file

    Nagant:
    -code-
    end

    M1:
    -code-
    end

    springfield:
    -code-
    end

    etc
  17. Herr Klugscheisser No longer supporting WarGaming

    Contributions:
    370
    Specialties:
    Scripting, Support
    Processing:
    Graphics:
    PREMIUM
    I Donated
    Actually Lamron taught me you can use commands "give" and "take" in the states. Here's an example from BT, so just change it to suit your needs.

    Code:
    state RAISE_HEAVY
    {
        movetype legs
    
        
        action
        {
            piat_crouch_raise             : IS_NEW_WEAPON "mainhand" "PIAT" POSITION_TYPE "crouching"
            piat_stand_raise                : IS_NEW_WEAPON "mainhand" "PIAT"
    
            shotgun_crouch_raise          : POSITION_TYPE "crouching" IS_NEW_WEAPON "mainhand" "Shotgun"
            shotgun_stand_raise        : IS_NEW_WEAPON "mainhand" "Shotgun"
            
            bazooka_crouch_raise          : POSITION_TYPE "crouching"
            bazooka_stand_raise        : default
        }
        
        states
        {
            FIX_BAZOOKA  : IS_WEAPON_ACTIVE "mainhand" "PIAT"
              FIX_BAZOOKA  : IS_WEAPON_ACTIVE "mainhand" "Bazooka"
            FIX_BAZOOKA  : IS_WEAPON_ACTIVE "mainhand" "Panzerschreck"
            STAND                     : KILLED        
            STAND                     : ANIMDONE_TORSO
            
            // allow immediate switching to a different weapon instead
            RAISE_ABORT                : +NEW_WEAPON
        }
    }
    
    
    
    //NEW STATE FILE
    state FIX_BAZOOKA
    {
             entrycommands
         {
                         take "models/weapons/bazooka.tik"
                       commanddelay 0.5 give "models/weapons/Mosin_Nagant_Rifle.tik"
                       commanddelay 0.5 forcetorsostate "STAND"
                       commanddelay 1 use "models/weapons/Mosin_Nagant_Rifle.tik"
             }
    }
    
    I didn't test it. It should give you some ideas. Just make another custom state for the Schreck if you like. It should give you a start. I've spent endless hours scratching my head as well .... so you're not alone.
    1 person likes this.
  18. -----DASH----- Corporal

    Contributions:
    15
    Specialties:
    Scripting
    Processing:
    Graphics:
    Take a look at this thread, where I ask for help for my rifle only mod:
    http://www.modtheater.com/forum/showthread.php?t=31735
    Most interesting for you probably is post #21 by Lamron. He wrote a script (that gets executed in the mike_torso.st at weapon raise) that makes it impossible to raise anything else than rifles, pistols and smoke nades. If you pick anything else than a bolt action rifle, you get one automatically.
    I can attach the full pk3, if you are interested.
  19. Herr Klugscheisser No longer supporting WarGaming

    Contributions:
    370
    Specialties:
    Scripting, Support
    Processing:
    Graphics:
    PREMIUM
    I Donated
    Yes, but people like Lamron, Sorrid & Hal taught me why run a script when you don't have to. ;)


    If it can be handled in a state mod it's quicker and less problematic.

    *NOTE* I changed the above torso edit because I forgot the take bazooka part .... :(
  20. ColonelIT Private

    Contributions:
    0
    I will give this a try and let you know how it works. Thanks!
Drop files here to upload
Draft saved Draft deleted

Share This Page